<?php
//including header.php 
include '../../include/header.php';
//including page.php (It is a class which contain functions)
include '../../libraries/page.php';
//created object for page.php
$page = new page();
session_start();

// checking the session
if (!$_SESSION['username']) {
    header("location:../user/login.php");
}
if ($_GET['q'] == 'logout') {
    $page->user_logout();
    header("location:../user/login.php");
}

// checking the data posted or not
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if ($_POST['chkDel'] == "") {
        $msg = $message[8];
    } else {
        $result = $page->delete("billno", "bills", $_POST['chkDel']);
        if ($result) {
            $msg = $message[2];
        } else {
            $msg = $message[0];
        }
    }
}
?>
<?
//including Navbar.php 
$sales_billing = 'active';
include '../../include/navbar.php';
?>

<!------------------css style sheets for responsive tables------------------------------------>
<link rel="stylesheet" type="text/css" href="../../css/sales_billing/style_table.css">
<link rel="stylesheet" type="text/css" href="../../css/sales_billing/responsive_table.css">

<?
// start the buffer
ob_start();
?>

<!-------------------------------------------Group selection options----------------->
<div class="group_select_desk">
    <span><strong style="font-size:22px;">Sales Billing</strong>
        <!---  <a onclick="javascript:checkAll('frmMain', false);" href="javascript:void();" style="float:right">uncheck all</a>
          <a onclick="javascript:checkAll('frmMain', true);" href="javascript:void();" style="float:right; margin-right: 20px;">check all</a></span>-->
        <!--<a href="javascript:reserveCheck('chkDel[]')" style="float:right">Invert Select</a>
        <a href="javascript:allCheck('chkDel[]',false)" style="float:right; margin-right: 20px;">Select None</a> 
        <a href="javascript:allCheck('chkDel[]',true)" style="float:right; margin-right: 20px;">Select All</a></span>-->

        <div class="btn-group"  style="float: right;margin-right: 10px">
            <a class="btn dropdown-toggle" data-toggle="dropdown" href="#" >
                More&nbsp;
                <span class="caret"></span>
            </a>
            <ul class="dropdown-menu"  style="float:left;margin-left: -84px;">
                <!-- dropdown menu links -->
                <li><a href =""><i class="icon-list"></i>Report</button></a>
                <li><a href =""><i class="icon-list-alt"></i>VAT Reports</a></li>
                <li><a href =""><i class="icon-th"></i>Options</a></li>             
            </ul>
        </div>
        <a href ="" style="float:right;margin-right: 10px"><button class="btn" type="button"><i class="icon-trash"></i>Delete</button></a>
        <div class="btn-group"  style="float: right;margin-right: 10px">
            <a class="btn dropdown-toggle" data-toggle="dropdown" href="#" >
                Check&nbsp;
                <span class="caret"></span>
            </a>
            <ul class="dropdown-menu"  style="float:left;margin-left: -84px">
                <!-- dropdown menu links -->
                <li><a href="javascript:allCheck('chkDel[]',true)">Select All</a></li>
                <li><a href="javascript:allCheck('chkDel[]',false)">Select None</a></li> 
                <li><a href="javascript:reserveCheck('chkDel[]')" >Invert Select</a></li>
            </ul>
        </div>
        <a href ="" style="float:right;margin-right: 10px"><button class="btn" type="button"><i class="icon-print"></i>Print</button></a>
        <a href ="add_sales_billing" style="float:right;margin-right: 10px"><button class="btn" type="button"><i class="icon-file"></i>New</button></a>
</div>
<div class="group_select_mob">
    <span><strong style="font-size:22px;">Sales Billing</strong></span><br>

    <div class="btn-group"  style="float: left">
        <a class="btn dropdown-toggle" data-toggle="dropdown" href="#" >
            Select&nbsp;
            <span class="caret"></span>
        </a>
        <ul class="dropdown-menu"  style="float:left;margin-left: -84px">
            <!-- dropdown menu links -->
            <li><a href="javascript:allCheck('chkDel[]',true)">Select All</a></li>
            <li><a href="javascript:allCheck('chkDel[]',false)">Select None</a></li> 
            <li><a href="javascript:reserveCheck('chkDel[]')" >Invert Select</a></li>   
        </ul>
    </div>
    <div class="btn-group"  style="float: right">
        <a class="btn dropdown-toggle" data-toggle="dropdown" href="#" >
            Action&nbsp;
            <span class="caret"></span>
        </a>
        <ul class="dropdown-menu"  style="float:left;margin-left: -84px">
            <!-- dropdown menu links -->
            <li><a href="add_sales_billing"><i class="icon-file"></i>New</a></li>
            <li><a href=""><i class="icon-print"></i>Print</a></li> 
            <li><a href="" ><i class="icon-list"></i>Report</a></li> 
            <li><a href="" ><i class="icon-list-alt"></i>VAT Report</a></li> 
            <li><a href="" ><i class="icon-th"></i>Options</a></li> 
        </ul>
    </div>
</div>

<br />

<!------------------------------Form------------------------------------->
<form name="frmMain" action="delete_bill.php" method="post" OnSubmit="return onDelete();">

    <!------------------------------Details Table------------------------------------->
    <table  class="table1 table-striped" style="margin-left: auto;margin-right: auto;margin-top: 15px; ">
        <thead  class="thead1">
            <tr>
                <th></th>
                <th>SL NO</th>
                <th>Bill#</th>
                <th>Date</th>
                <th>To</th>
                <th>Total</th>
                <th>Discount</th>
                <th>Net Amount</th>          
                <th>Edit</th>
            </tr>
        </thead>
        <tbody>
           
                <?
            //php code to get the data from suppliers table 
            $bills = mysql_query("select * from bills");
            $id = 0;
            while ($bills_data = mysql_fetch_array($bills)) {

            $bills_id = $bills_data['billno'];
            $date = $bills_data['date'];
            $to = $bills_data['billto'];
            $total = $bills_data['total'];
            $discount = $bills_data['discount'];
            $amount = $bills_data['amount'];
            $id++;
            ?>
          

            <!-------------------------Dynamic row to display from database--------------------->
          <tr>
                <td><input type="checkbox" name="chkDel[]" id="chkDel<?= $i; ?>" value="<? echo $bills_id; ?>"></td>
                <td><? echo $id; ?></td>
                <td><a href="sales_billing_update?id=<?= $bills_id; ?>"><?= $bills_id; ?></a></td>
                <td><?= $date ?></td>
                <td><?= $to ?></td>
                <td><?= $total ?></td>
                <td><?= $discount ?></td>
                <td><?= $amount ?></td>
                <td><a href="sales_billing_update?id=<?= $bills_id; ?>">Edit</a></td>
            </tr>

            <?
            // Closing the loop
            }
            ?>
        </tbody>
    </table>
    <!----------------------------CRUD Buttons-------------------------------------->
    <div align="center" style="margin-top:10px">
        <a href="add_sales_billing"><button class="btn btn-primary" type="button">Add</button></a>
        <button class="btn btn-danger" type="submit">Delete</button>
    </div>
</form>
<?php
//including footer.php
include '../../include/footer.php';
// flush the buffer
flush();
?>

